package com.hyt.it.ogt.pj.feign.tps;

import org.springframework.stereotype.Component;

import com.hyt.common.utils.exception.RemoteRequestExcepton;
import com.hyt.common.utils.result.Result;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

/**
 * feign客户端熔断器
 */
@Component
@Slf4j
public class TpsClientHystrix implements FallbackFactory<TpsClient> {

    @Override
    public TpsClient create(Throwable throwable) {
        log.error("# TpsClient Hystrix message ", throwable);

        return new TpsClient() {
            @Override
            public Result uploadFileToHuawei(String officeId, String path, byte[] bytes) {
                log.error("#调用失败，进入熔断");
                throw new RemoteRequestExcepton("调用失败");
            }

			@Override
			public String getBucketTempCredential() {
				log.error("#查询失败，进入熔断");
                throw new RemoteRequestExcepton("查询失败");
			}
        };
    }
}
